home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Toolbox / Visual Basic Toolbox (P.I.E.)(1996).ISO / disk_utl / advapp / frmmove.frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1994-12-12  |  8.3 KB  |  260 lines

  1. VERSION 2.00
  2. Begin Form frmMove 
  3.    BackColor       =   &H00C0C0C0&
  4.    Caption         =   "Move File 'From' -> 'To'"
  5.    ClientHeight    =   4785
  6.    ClientLeft      =   3090
  7.    ClientTop       =   1620
  8.    ClientWidth     =   4755
  9.    Height          =   5190
  10.    Left            =   3030
  11.    LinkTopic       =   "Form1"
  12.    MaxButton       =   0   'False
  13.    MinButton       =   0   'False
  14.    ScaleHeight     =   4785
  15.    ScaleWidth      =   4755
  16.    Top             =   1275
  17.    Width           =   4875
  18.    Begin CheckBox chkNewerRevision 
  19.       BackColor       =   &H00C0C0C0&
  20.       Caption         =   "Over Write Newer Revisions."
  21.       Height          =   255
  22.       Left            =   240
  23.       TabIndex        =   9
  24.       Top             =   3600
  25.       Width           =   4215
  26.    End
  27.    Begin CommandButton cmdTo 
  28.       Caption         =   "Exists"
  29.       Height          =   285
  30.       Left            =   3720
  31.       TabIndex        =   3
  32.       Top             =   480
  33.       Width           =   855
  34.    End
  35.    Begin CommandButton cmdFrom 
  36.       Caption         =   "Exists"
  37.       Height          =   285
  38.       Left            =   3720
  39.       TabIndex        =   1
  40.       Top             =   120
  41.       Width           =   855
  42.    End
  43.    Begin CheckBox chkOverWrite 
  44.       BackColor       =   &H00C0C0C0&
  45.       Caption         =   "Over Write file if file already exists."
  46.       Height          =   255
  47.       Left            =   240
  48.       TabIndex        =   8
  49.       Top             =   3240
  50.       Width           =   4215
  51.    End
  52.    Begin Frame Frame2 
  53.       BackColor       =   &H00C0C0C0&
  54.       Caption         =   "Create ? "
  55.       Height          =   1095
  56.       Left            =   240
  57.       TabIndex        =   15
  58.       Top             =   840
  59.       Width           =   4335
  60.       Begin OptionButton optDirectory 
  61.          BackColor       =   &H00C0C0C0&
  62.          Caption         =   "No Directory, No Move."
  63.          Height          =   255
  64.          Index           =   1
  65.          Left            =   240
  66.          TabIndex        =   5
  67.          Top             =   720
  68.          Width           =   3975
  69.       End
  70.       Begin OptionButton optDirectory 
  71.          BackColor       =   &H00C0C0C0&
  72.          Caption         =   "Create Directory with Move."
  73.          Height          =   255
  74.          Index           =   0
  75.          Left            =   240
  76.          TabIndex        =   4
  77.          Top             =   360
  78.          Width           =   3975
  79.       End
  80.    End
  81.    Begin Frame Frame1 
  82.       BackColor       =   &H00C0C0C0&
  83.       Caption         =   "Delete ? "
  84.       Height          =   1095
  85.       Left            =   240
  86.       TabIndex        =   14
  87.       Top             =   2040
  88.       Width           =   4335
  89.       Begin OptionButton optDelete 
  90.          BackColor       =   &H00C0C0C0&
  91.          Caption         =   "No Not Delete File with Move."
  92.          Height          =   255
  93.          Index           =   1
  94.          Left            =   240
  95.          TabIndex        =   7
  96.          Top             =   720
  97.          Width           =   3735
  98.       End
  99.       Begin OptionButton optDelete 
  100.          BackColor       =   &H00C0C0C0&
  101.          Caption         =   "Delete 'From' File with Move"
  102.          Height          =   255
  103.          Index           =   0
  104.          Left            =   240
  105.          TabIndex        =   6
  106.          Top             =   360
  107.          Width           =   3735
  108.       End
  109.    End
  110.    Begin CommandButton Cancel 
  111.       Caption         =   "&Cancel"
  112.       Height          =   375
  113.       Left            =   2880
  114.       TabIndex        =   11
  115.       Top             =   4200
  116.       Width           =   855
  117.    End
  118.    Begin TextBox txtTo 
  119.       Height          =   285
  120.       Left            =   1320
  121.       TabIndex        =   2
  122.       Text            =   "Text1"
  123.       Top             =   480
  124.       Width           =   2295
  125.    End
  126.    Begin TextBox txtFrom 
  127.       Height          =   285
  128.       Left            =   1320
  129.       TabIndex        =   0
  130.       Text            =   "Text1"
  131.       Top             =   120
  132.       Width           =   2295
  133.    End
  134.    Begin CommandButton cmdOK 
  135.       Caption         =   "&OK"
  136.       Height          =   375
  137.       Left            =   1080
  138.       TabIndex        =   10
  139.       Top             =   4200
  140.       Width           =   855
  141.    End
  142.    Begin Line Line1 
  143.       X1              =   240
  144.       X2              =   4560
  145.       Y1              =   4080
  146.       Y2              =   4080
  147.    End
  148.    Begin Label Label2 
  149.       BackColor       =   &H00C0C0C0&
  150.       Caption         =   "File To:"
  151.       Height          =   255
  152.       Left            =   240
  153.       TabIndex        =   13
  154.       Top             =   480
  155.       Width           =   975
  156.    End
  157.    Begin Label Label1 
  158.       BackColor       =   &H00C0C0C0&
  159.       Caption         =   "File From:"
  160.       Height          =   255
  161.       Left            =   240
  162.       TabIndex        =   12
  163.       Top             =   120
  164.       Width           =   975
  165.    End
  166. '''''''''''''''''''''''''''''''''''''''''''''''''
  167. ' Copyright by Advanced Applications 1994 - 1995
  168. ' All rights reserved
  169. '''''''''''''''''''''''''''''''''''''''''''''''''
  170. Dim nDirectoryCreate As Integer
  171. Dim nDelete As Integer
  172. Dim nOverWrite As Integer
  173. Dim nNewerRevision As Integer
  174. '===============================================================
  175. ' The Move/Copy File Flow:
  176. '===============================================================
  177. ' 1. Check for the existance of the 'From' File
  178. '    return = 104; if the 'From' File does not exist
  179. ' 2. Get information on the 'To' disk drive
  180. '    return = Disk Info error code; Free Disk Space Error
  181. '    return = 105; No Disk Space left
  182. ' 3. Compare 'From' File length to 'To' Drive
  183. '    return = 106; Not enough room for file
  184. ' 4. Create the Directory, by user
  185. '    return = 107; Directory Creation error
  186. ' 5. Directory does not exist, user asked not to create it and
  187. '    move the file.
  188. '    return = 108; Directory not created and file not moved
  189. ' 6. return = 100 - File could not be opened for the Write, or
  190. '             101 - 'From' File could not be closed, or
  191. '             102 - 'To' File could not be closed. or
  192. '             103 - Could not delete the 'From' File.
  193. ' 7. Checks for Newer Revision of the 'To' File
  194. '    return = 109 - The "To' File is a New Revision, operation cancelled
  195. ' 8. return = 0; No Errors, done.
  196. '================================================================
  197. Sub Cancel_Click ()
  198.     Me.Hide
  199.     DoEvents
  200. End Sub
  201. Sub chkNewerRevision_Click ()
  202.     nNewerRevision = chkNewerRevision.Value
  203. End Sub
  204. Sub chkOverWrite_Click ()
  205.     nOverWrite = chkOverWrite.Value
  206. End Sub
  207. Sub cmdFrom_Click ()
  208.     If txtFrom.Text = "" Then Exit Sub
  209.     strFrom$ = txtFrom.Text
  210.     nReturn% = FileExists(strFrom$)
  211.     If nReturn% = FILE_EXISTS Then
  212.     MsgBox "File Exists"
  213.     Else
  214.     MsgBox "File Does Not Exist"
  215.     End If
  216. End Sub
  217. Sub cmdOK_Click ()
  218.     If txtFrom.Text = "" Or txtTo.Text = "" Then Exit Sub
  219.     strFrom$ = txtFrom.Text
  220.     strTo$ = txtTo.Text
  221.     Screen.MousePointer = HOURGLASS
  222.     lReturn& = MoveCopyFile(strFrom$, strTo$, nDirectoryCreate, nDelete, nOverWrite, nNewerRevision)
  223.     If lReturn& <> 0 Then
  224.     DisplayError lReturn&
  225.     End If
  226.     Screen.MousePointer = DEFAULT
  227.     Me.Hide
  228.     DoEvents
  229. End Sub
  230. ' The FileExists([file]) can be used to test for the
  231. ' existance of the file prior to using the MoveFileTo()
  232. ' command. With the MoveFileTo setup properly, this
  233. ' command will act just like a copy.
  234. Sub cmdTo_Click ()
  235.     If txtTo.Text = "" Then Exit Sub
  236.     strFrom$ = txtTo.Text
  237.     nReturn% = FileExists(strFrom$)
  238.     If nReturn% = 0 Then
  239.     MsgBox "File Exists"
  240.     Else
  241.     MsgBox "File Does Not Exist"
  242.     End If
  243. End Sub
  244. Sub Form_Load ()
  245.     Left = (Screen.Width - Width) / 2   ' Center form horizontally.
  246.     Top = (Screen.Height - Height) / 2  ' Center form vertically.
  247.     txtFrom.Text = ""
  248.     txtTo.Text = ""
  249.     optDirectory(0).Value = True
  250.     optDelete(0).Value = True
  251.     chkOverWrite.Value = 0
  252.     chkNewerRevision.Value = 0
  253. End Sub
  254. Sub optDelete_Click (Index As Integer)
  255.     nDelete = Index
  256. End Sub
  257. Sub optDirectory_Click (Index As Integer)
  258.     nDirectoryCreate = Index
  259. End Sub
  260.